home *** CD-ROM | disk | FTP | other *** search
- //==============================================================
- // Memory Interleave Tester:
- // 7/25/97
- //
- // Copyright: © 1997 by Apple Computer, Inc., all rights reserved.
- //
- // You may incorporate this sample code into your applications without
- // restriction, though the sample code has been provided "AS IS" and the
- // responsibility for its operation is 100% yours. However, what you are
- // not permitted to do is to redistribute the source as "DSC Sample Code"
- // after having made changes. If you're going to re-distribute the source,
- // we require that you make it clear in the source that the code was
- // descended from Apple Sample Code, but that you've made changes.
- //
- // Change History:
- // • Formerly, we were using Gestalt to see if we should run, and hard
- // coded the machines that it worked on. Now, just use the FindHammerHead
- // function, and if it works, use it, else bail out.
- // • Also still hard code to given machines, in order to print out the list of
- // installed ram, and give the physical locations of the DIMM slots.
- //
- //==============================================================
- // This is a test application to demonstrate how to call the TestBanks
- // routine, in order to determine if the RAM installed in the computer
- // is being used in an interleaved fashion or not. Interleaved memory
- // is substantially faster, up to twice as fast as non-interleaved.
- //
- // The program needs to figure out which machine it is on specifically, so that
- // it can make a mapping between physical DIMM slots, and what the Hammerhead
- // registers come back with. Naturally this couldn't be a simple one to one mapping,
- // these are computers.
- // So, there are machine specific print out routines, which take the array data and
- // turn it into a form that makes sense. If we don't have a specific machine match,
- // then we do a generic version, so that you can see what it looks like, even though
- // we cannot give you the physical mapping.
- //
- // Quick, dirty, and comes with no warranty. This will only work on
- // PowerMac's that support a version of the HammerHead memory controller.
- // Nothing else is allowed to run. Since we look at the hardware directly,
- // naturally it's machine dependent.
- //
- // However, if you have any trouble with it, please contact Apple's DTS,
- // at <devsupport@apple.com>
- //
- // Peter Baum, Bo3b Johnson, and Quinn.
-
- #include <gestalt.h>
- #include <stdio.h>
- #include <Types.h>
-
- #include "Interleave.h"
-
-
- //==============================================================
- // Print a given Bank's information. Just a common routine, for display.
-
- static void
- PrintBankInfo(short k, RAMBankDescriptorPtr theBanks)
- {
- printf ("%3.0d/%3.0d ", theBanks[k].bankSize, theBanks[k+1].bankSize);
-
- if (theBanks[k].bankIsInterleaved)
- printf ("Interleaved");
- else
- printf(" --- ");
-
- printf("\n");
- }
-
-
- //==============================================================
- // The loop counters go by funny numbers in order to display the banks
- // in a reasonable order. (ie. A1/B1 front, A1/B1 back.)
- // This maps the memory installed into the physical slot numbers that
- // are silk screened onto the motherboard. Front & Back don't really mean
- // that...they are just nomenclature for two banks per DIMM.
- //
- // The first two banks, 0, and 1, are skipped, because they are for the
- // MotherBoard banks, which don't exist on these computers.
-
- static void
- Print75008500 (RAMBankDescriptorPtr theBanks)
- {
- short i;
- short j;
- OSErr err;
-
- printf ("Motherboard Row-> not implemented\n");
-
- for (i=1; i<=4; i++)
- {
- printf ("A%d/B%d (row 0) -> ", i, i);
- j = 18-(4*i);
- PrintBankInfo(j, theBanks);
-
- printf ("A%d/B%d (row 1) -> ", i, i);
- j = 20-(4*i);
- PrintBankInfo(j, theBanks);
- }
- }
-
-
- //==============================================================
- // The first two banks, 0, and 1, are skipped, because they are for the
- // MotherBoard banks, which don't exist on these computers.
-
- static void
- Print9500 (RAMBankDescriptorPtr theBanks)
- {
- short i;
- short j;
- OSErr err;
-
- printf ("Motherboard Row-> not implemented\n");
-
- // Decipher the bank information, and display it.
- for (i=1; i<=6; i++)
- {
- printf ("A%d/B%d (row 0) -> ", i, i);
- j = (4*i)-2;
- PrintBankInfo(j, theBanks);
-
- printf ("A%d/B%d (row 1) -> ", i, i);
- j = 4*i;
- PrintBankInfo(j, theBanks);
- }
- }
-
- //==============================================================
- // If we don't know which machine we are on, but we got the BankInfo, then
- // we have a new machine we don't know about. Dump out the memory in a
- // generic form, so they can see what's in the HammerHead registers.
-
- static void
- PrintGenericMac (RAMBankDescriptorPtr theBanks)
- {
- short i;
- short j;
- OSErr err;
-
- // Since PrintBankInfo just prints two slots at a time, just increment through them.
- for (i = 0; i < 13; i++)
- {
- printf ("x%d/x%d -> ", i, i);
- j = 2 * i;
- PrintBankInfo(j, theBanks);
- }
- }
-
- //==============================================================
- // Get physical memory in Megabytes.
-
- static UInt32
- GetPhysicalMemSize()
- {
- long myAttr;
- long theSize;
- OSErr err;
-
- err = Gestalt( gestaltPhysicalRAMSize, &myAttr);
- if (err == noErr)
- theSize = myAttr / (1024*1024);
- else
- theSize = 0;
-
- return(theSize);
- }
-
-
- //==============================================================
- void
- main()
- {
- OSErr err;
- long machineAttribute;
- Ptr hammerHeadAddress;
- long theRAMSize;
- RAMBankDescriptor allBanks[26];
-
-
- printf ("Welcome to the Display DIMM Configuration\n\n");
- printf ("A Primer on DIMMs:\n");
- printf ("Each DIMM in the 7500/8500/9500 can support two 'rows' of memory.\n");
- printf ("You can't tell by looking at the RAM (i.e. it doesn't matter if it's \n");
- printf ("got RAM on both sides of DIMM.) Most DIMMs have only a single row.\n");
- printf ("The 7500/8500 has 8 DIMM slots labelled A1 thru A4 and B1 thru B4.\n");
- printf ("The 9500 has 12 DIMM slots labelled A1 thru A6 and B1 thru B6.\n\n");
- printf ("To interleave memory, the DIMM in slot Ax must match the DIMM in Bx.\n");
- printf ("In the list below, each line represents a pair of slots which can \n");
- printf ("be interleaved. If the pair of DIMMs is interleaved properly \n");
- printf ("the word 'Interleaved' will appear at the end of the line. \n\n");
- printf ("by Peter Baum, Bo3b Johnson, Quinn - v1.1 © 1996 Apple Computer, Inc. \n\n\n");
-
- // FindHammerHead is a well behaved routine, and so we can just call it without
- // worrying about computer and so on. If this machine has a HammerHead, we
- // get noErr, and the result. Otherwise, we don't support the current machine.
- err = FindHammerHead(&hammerHeadAddress);
-
- if (err != noErr) {
- printf("---Unsupported Macintosh---");
- return; // waits for them to Command-Q to leave.
- }
-
-
- // Start the display with the total memory in the machine.
- theRAMSize = GetPhysicalMemSize();
- if (theRAMSize == 0) {
- printf ("---Error getting memory size---\n");
- return;
- }
- else {
- printf ("Total Memory = %d Megs in \n", theRAMSize);
- }
-
-
- // Ask the routine to fetch the RAM Bank info. Fill out the descriptors.
- err = GetPhysicalRAMBankInfo(allBanks, theRAMSize, hammerHeadAddress);
- if (err != noErr) {
- printf ("---Couldn't get info on the banks---\n");
- return;
- }
-
- // Decide what machine we are on, and display the RAM banks data that
- // currently is installed.
- err = Gestalt(gestaltMachineType, &machineAttribute);
- switch (machineAttribute)
- {
- case gestaltPowerMac7500:
- printf ("7500 DIMM Slots: Meg/Meg 'Interleaved'\n");
- printf (" ---/--- \n");
- Print75008500(allBanks);
- break;
-
- case gestaltPowerMac8500:
- printf ("8500 DIMM Slots: Meg/Meg 'Interleaved'\n");
- printf (" ---/--- \n");
- Print75008500(allBanks);
- break;
-
- case gestaltPowerMac9500:
- printf ("9500 DIMM Slots: Meg/Meg 'Interleaved'\n");
- printf (" ---/--- \n");
- Print9500(allBanks);
- break;
-
- default:
- printf ("Unknown PowerMac: Meg/Meg 'Interleaved'\n");
- printf (" ---/--- \n");
- PrintGenericMac(allBanks);
- break;
- }
- }
-
-
-
-
-